import java.util.*;

public class Solution {

    Stack<Integer> stack;
    Stack<Integer> helper;

    public Solution(){
        stack =new Stack<Integer>();
        helper=new Stack<Integer>();
    }

    public void push(int node) {
        stack.push(node);

    }

    public void pop() {
        stack.pop();

    }

    public int top() {
        int res=stack.peek();
        return res;

    }
    //把栈内的所有元素搬出来，找到最小
    //再放回去
    public int min() {
        int ans=Integer.MAX_VALUE;
        while(!stack.isEmpty()){

            int res=stack.pop();
            if(res<ans){
                ans=res;
            }
            helper.push(res);
        }
        while(!helper.isEmpty()){
            int a=helper.pop();
            stack.push(a);
        }

        return ans;
    }
}
